package com.info.zhiduoduo.common.constants.project;

import com.google.common.collect.Lists;
import com.info.zhiduoduo.common.utils.NumberUtil;

import java.util.List;

/**
 * 项目状态 1草稿 2待发布 4已发布 6竞标中(创客已投标) 7竞标失败 8竞标结束 10进行中 12验收中 13 验收完成 14 拒绝验收 15待线下支付 20已完成 21:已作废(已完成的项目作废) 44删除
 */
public interface CompanyProjectState {

	int DRAFT = 1;
	int WAIT_SUBMIT = 2;
	int SUBMIT_FAILED = 3;
	int SUBMITTED = 4;
	int BIDDING = 6;
	int BID_FAILED = 7;
	int BID_FINISH = 8;
	int PROCESSING = 10;
	int CHECKING = 12;
	int CHECKED = 13;
	int CHECK_REFUSED = 14;
	int WAIT_OFFLINE_PAY = 15;
	int COMPLETED = 20;
	int USELESS = 21;
	int CANCELLED = 40;
	int DELETED = 44;

	/**
	 * 是否是可取消的项目状态，只要未验收成功，都可取消
	 *
	 * @param state
	 * @return
	 */
	static boolean isCancelable(int state) {
		return NumberUtil.intIn(state, DRAFT, WAIT_SUBMIT, SUBMIT_FAILED, SUBMITTED, BIDDING, BID_FAILED, BID_FINISH, PROCESSING, CHECKING,
				CHECK_REFUSED);
	}

	/**
	 * 如果正在取消项目，则满足这几个状态的需要退款。
	 *
	 * @param state
	 * @return
	 */
	static boolean refundWhileCancelling(int state) {
		return NumberUtil.intIn(state, PROCESSING, CHECKING, CHECK_REFUSED);
	}

	static List<Integer> deleteDraftStates() {
		return Lists.newArrayList(DRAFT, WAIT_SUBMIT, SUBMIT_FAILED, SUBMITTED, BIDDING, BID_FAILED, BID_FINISH);
	}

	static boolean isDeletable(int state) {
		return NumberUtil.intIn(state, DRAFT, WAIT_SUBMIT, SUBMIT_FAILED, SUBMITTED, BIDDING, BID_FAILED, BID_FINISH);
	}
}
